

import wx

import const as CONST

class PopupFrame(wx.Panel):
    def __init__(self, parent):
        self.parent = parent
        
        wx.Panel.__init__(self, parent, -1)
        

        self.SetBackgroundColour(CONST.CONS_POP_COLOR)
        
        
        
        self.setSize()
#        self.Show(True)
        self.Refresh(True)
        
    def setBindings(self):
        self.Bind(wx.EVT_LEFT_DOWN, self.parent.OnLeftDown)
        self.Bind(wx.EVT_LEFT_UP, self.parent.OnLeftUp)
        self.Bind(wx.EVT_MOTION, self.parent.OnMouseMove)
        
    def pop(self, show = True):
        if not CONST.SHOW_POP:
            self.Show(False)
            self.parent.setDefsize()
        else:
            self.Show(show)
        
        
        
    def setSize(self):
        if CONST.SHOW_POP:
            x, y = self.parent.pos
            w, h = self.parent.wh
            sX = x
            sY = y+h+2
            nW, nH = w, h+2+400
            nr = wx.Region(0, 0, nW, nH)
            self.parent.region = nr
            self.parent.SetShape(nr)
            self.SetPosition((0, 32))
            self.SetSize((w, 400))

